<?php

namespace core\handler;


class ExceptionHandler
{
    // 这是一个很粗暴的异常处理函数
    // todo 把这个改了吧 求求你了
    public static function handler(\Throwable $throwable) {
        echo json_encode([
            'code'  => $throwable->getCode(),
            'msg'   => $throwable->getMessage(),
            'line'  => $throwable->getLine(),
            'file'  => $throwable->getFile(),
            'prev'  => $throwable->getPrevious(),
            'trace' => $throwable->getTrace()
        ], JSON_UNESCAPED_UNICODE);
        exit($throwable->getCode());
    }
    public static function register() {
        set_exception_handler([__CLASS__, 'handler']);
    }
}